package com.semp.jadoma.core.service;

import java.util.Date;

import com.semp.jadoma.core.dao.DogReferenceDAO;
import com.semp.jadoma.core.dao.FamilyDAO;
import com.semp.jadoma.core.model.DogReference;
import com.semp.jadoma.core.model.Family;

public class FamilyService {

	private final static FamilyService instance = new FamilyService();
	
	private FamilyService() {}
	
	public static FamilyService getInstance() {
		return instance;
	}
	
	/**
	 * Creates a family
	 * @param birthDay
	 * @param fatherId
	 * @param motherId
	 * @return
	 */
	public Family createFamily(Date birthDay, long fatherId, long motherId) {
		Family family = new Family();
		family.setBirthDay(birthDay);
		DogReference fReference = DogReferenceDAO.find(fatherId);
		DogReference mReference = DogReferenceDAO.find(motherId);
		family.setFather(fReference);
		family.setMother(mReference);
		FamilyDAO.update(family);
		return family;
	}
	
	/**
	 * load a family
	 * @param familyId
	 * @return
	 */
	public Family getFamily(long familyId) {
		//Load Familly
		return FamilyDAO.find(familyId);
	}
}
